package parser;

import antlr.RecognitionException;
import antlr.Token;

class Unary extends Expr {
    
    Expr expr;
    int opID;
    
    Unary(String op, Expr expr) {
        this.opID = NameTable.getOperatorIndex(op);
        this.expr = expr;
    }
    
    void write(ByteStream out) throws RecognitionException {
        expr.write(out);
        out.write(Opcodes.UNARY);
        out.write(opID);
    }
    
    void writeLHS(ByteStream out) throws RecognitionException {
        throw new RecognitionException("Cannot assign to unary operator");
    }

    void delete(ByteStream out) throws RecognitionException {
        throw new RecognitionException("Cannot delete rvalue");
    }
    
}
